h= input()
a= input()
ad, hd = dict(), dict()
sa, sh = set(), set()
for _ in range(int(input())):
t, n, p, f = input().split()
if f == 'y' and n =='h':
if p in hd and p not in sh:
hd[p] += 1
if hd[p] == 2:
sh.add(p)
print(h, p, t)
else:
hd[p] = 1
if f == 'y' and n =='a':
if p in ad and p not in sa:
ad[p] += 1
if ad[p] == 2:
sa.add(p)
print(a, p, t)
else:
ad[p] = 1
if f=='r' and n == 'a' and p not in sa:
sa.add(p)
print(a, p, t)
if f=='r' and n=='h' and p not in sh:
sh.add(p)
print(h, p, t)
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
int main() {
string homeTeam, awayTeam;
cin >> homeTeam >> awayTeam;
int n;
cin >> n;
map<int , int > yellowCardsHOME;
map<int , int > yellowCardsAWAY;
set <int> firedHOME;
set <int> firedAWAY;
for (int i = 0; i < n; i++) {
int time, player ;
char team;
char card;
cin >> time >> team >> player >>card;
if (team == 'h') {
if ( (card == 'r' || (card == 'y' && yellowCardsHOME[player] == 1 )) && firedHOME.find(player) == firedHOME.end()){
cout << homeTeam << " " << player << " " << time << endl;
firedHOME.insert(player);
} else {
yellowCardsHOME[player]++;
}
} else {
if ( (card == 'r' || (card == 'y' && yellowCardsAWAY[player] == 1 )) && firedAWAY.find(player) == firedAWAY.end()) {
cout << awayTeam << " " << player << " " << time << endl;
firedAWAY.insert(player);
} else {
yellowCardsAWAY[player]++;
}
}
}
}
1663D - Is it rated - 3 | 1311A - Add Odd or Subtract Even |
977F - Consecutive Subsequence | 939A - Love Triangle |
755A - PolandBall and Hypothesis | 760B - Frodo and pillows |
1006A - Adjacent Replacements | 1195C - Basketball Exercise |
1206A - Choose Two Numbers | 1438B - Valerii Against Everyone |
822A - I'm bored with life | 9A - Die Roll |
1430B - Barrels | 279B - Books |
1374B - Multiply by 2 divide by 6 | 1093B - Letters Rearranging |
1213C - Book Reading | 1468C - Berpizza |
1546B - AquaMoon and Stolen String | 1353C - Board Moves |
902A - Visiting a Friend | 299B - Ksusha the Squirrel |
1647D - Madoka and the Best School in Russia | 1208A - XORinacci |
1539B - Love Song | 22B - Bargaining Table |
1490B - Balanced Remainders | 264A - Escape from Stones |
1506A - Strange Table | 456A - Laptops |